#include "stdafx.h"
#include "myspirit.h"

MySpirit::MySpirit(CImage* img, int frameWidth, int frameHeight):CSpirit(img,frameWidth,frameHeight){

	willChange=false;
	nextSequence=NULL;
	nextState=NULL;
	nextSeqLength=0;
	nextImage=NULL;
	nextFrameWidth=0;
	nextFrameHeight=0;
	isChangeImage=false;
}

void MySpirit::NextFrame(){
	if(willChange&&currentFrame==seqLength-1){
		CSpirit::SetFrameSequence(nextSequence,nextSeqLength);
		willChange=false;

	}
	if(isChangeImage&&currentFrame==seqLength-1){
		CSpirit::SetImage(nextImage,nextFrameWidth,nextFrameHeight);
		isChangeImage=false;
		//willChange=false;
	}
	CSpirit::NextFrame();
	

}
void MySpirit::SetFrameSequence(int *sequence, int seqLength){
	nextSeqLength=seqLength;
	nextSequence=sequence;
	willChange=true;
}

void MySpirit::SetImage(CImage * img,int frameWidth,int frameHeight){
    nextImage=img;
	nextFrameWidth=frameWidth;
	nextFrameHeight=frameHeight;
	//willChange=true;
	isChangeImage=true;
}
